# -*- coding:UTF-8 -*-
'''
开发环境：PyCharm
创建日期：2025/8/21 10:57
作   者：新启典学苑-樱桃
描   述：
'''
import configparser
import os

import yaml


def get_project_path():
    cf = os.path.realpath(__file__) # 当前文件路径  readfile.py
    cd = os.path.dirname(cf) # util
    cd = os.path.dirname(cd) # inrongApiAutoTest
    return cd + "/"

def read_ini(path, section, key):
    path = get_project_path() + path
    cp = configparser.ConfigParser() # 创建一个对象
    cp.read(path, encoding="UTF-8") # 读配置文件
    return cp.get(section, key) # 获取value

def read_yaml(path):
    path = get_project_path() + path
    # pyyaml 专门处理yaml的库， pip install pyyaml
    # 当作普通文件读取
    with open(path, "r", encoding="utf-8") as f:
        content = f.read()
    # 把文件内容解析成yaml格式
    return yaml.safe_load(content)

# 测试代码，用完删除
if __name__ == '__main__':
    a = read_yaml("/data/register_data.yaml")
    print(a)  # 列表嵌套字典



